<?php
/**
 * Created by PhpStorm.
 * User: lelouchms
 * Date: 2019/5/19
 * Time: 15:57
 */

namespace app\common\controller;


trait ReturnData
{

    public function ok($data = '', $message = 'ok')
    {
        $responseData = [
            "code" => 200,
            "message" => $message,
        ];
        if (!empty($data)) $responseData["data"] = $data;
        return json($responseData);
    }

    public function fail($message)
    {
        return json([
            "code" => 400,
            "message" => $message
        ]);
    }

}